<style>
    #groupline-add {
        padding: 20px 25px 25px 0;
    }

    .layui-form-select dl {
        max-height: 150px;
    }
</style>
<div class="layui-fluid" id="dept-edit">
    <form class="layui-form" lay-filter="dept-update-form" style="margin-top: 15px;">
        <div class="layui-form-item febs-hide">
            <label class="layui-form-label">id：</label>
            <div class="layui-input-block">
                <input type="hidden" name="deptId" >
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label febs-form-item-require">机构名称：</label>
            <div class="layui-input-block">
                <input type="text" lay-verify="required" name="deptName"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label febs-form-item-require">机构名称：</label>
            <div class="layui-input-block">
                <input type="text" lay-verify="required" name="deptCode"
                       autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">省份：</label>
            <div class="layui-input-block">
                <select name="province" lay-search>
                    <option value="">请选择</option>
                    <option value="北京">北京</option>
                    <option value="上海">上海</option>
                    <option value="天津">天津</option>
                    <option value="重庆">重庆</option>
                    <option value="内蒙古">内蒙古</option>
                    <option value="山西">山西</option>
                    <option value="河北">河北</option>
                    <option value="辽宁">辽宁</option>
                    <option value="吉林">吉林</option>
                    <option value="黑龙江">黑龙江</option>
                    <option value="江苏">江苏</option>
                    <option value="安徽">安徽</option>
                    <option value="山东">山东</option>
                    <option value="浙江">浙江</option>
                    <option value="江西">江西</option>
                    <option value="福建">福建</option>
                    <option value="湖南">湖南</option>
                    <option value="湖北">湖北</option>
                    <option value="河南">河南</option>
                    <option value="广东">广东</option>
                    <option value="海南">海南</option>
                    <option value="广西">广西</option>
                    <option value="贵州">贵州</option>
                    <option value="四川">四川</option>
                    <option value="云南">云南</option>
                    <option value="陕西">陕西</option>
                    <option value="甘肃">甘肃</option>
                    <option value="宁夏">宁夏</option>
                    <option value="青海">青海</option>
                    <option value="新疆">新疆</option>
                    <option value="西藏">西藏</option>
                    <option value="香港">香港</option>
                    <option value="澳门">澳门</option>
                    <option value="台湾">台湾</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">机构地址：</label>
            <div class="layui-input-block">
                <input type="text" name="address"
                       autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">联系方式：</label>
            <div class="layui-input-block">
                <input type="text" name="contact"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label ">排序：</label>
            <div class="layui-input-block">
                <input type="text"  name="orderNum"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item febs-hide">
            <button class="layui-btn" lay-submit="" lay-filter="dept-update-form-submit" id="submit"></button>
        </div>
    </form>
</div>
<script th:src="@{/febs/js/system/dept/edit.js(v=1)}"></script>
<script data-th-inline="javascript">
    layui.use(['febs', 'form', 'layer'], function () {
        var $ = layui.$,
            febs = layui.febs,
            layer = layui.layer,
            form = layui.form,
            dept = [[${dept}]],
            $view = $('#dept-edit'),
            $form = $view.find("form");

        form.render();

        form.on('submit(dept-update-form-submit)', function (data) {
            var deptId = data.field.deptId;
            var url = ctx + 'dept';
            if (deptId && deptId.length > 0) {
                url = ctx + 'dept/update';
            }
            febs.post(url, data.field, function () {
                layer.closeAll();
                febs.alert.success('保存成功');
                $('#febs-dept').find('#query').click();
            });
            return false;
        });

        initFormValue();

        function initFormValue() {
            if (dept) {
                form.val("dept-update-form", {
                    "deptId": dept.deptId,
                    "deptName": dept.deptName,
                    "deptCode": dept.deptCode,
                    "province": dept.province,
                    "address": dept.address,
                    "contact": dept.contact,
                });
            }
        }
    });
</script>